import goodStorage from 'good-storage'

const app = {
  state: {  // 这里
    user: {
      token: '',
      expires: '',
      userName: '',
      nickname: ''
    }
  },
  mutations: {
    GET_TOKEN: (state, view) => {
      return state.user
    },
    SET_USER: (state, view) => {
      state.user = view
      goodStorage.set('user', view)
    },
    REMOVE_USER: (state, view) => {
      state.user = view
      goodStorage.remove('user')
    }
  },
  actions: {
    // 第一个参数为 Store 对象 可以通过 {} 来直接获取Store对象中的属性 如下：
    // 这里的第一个参数为 Store.commit
    delVisitedViews: ({commit}, view) => {
      commit('DEL_VISITED_VIEWS', view)
    }
  }
}

export default app
